﻿using System.ComponentModel;
using System.Web.UI;
using Besture.Bll;

namespace Besture.CmsControl
{
    [DefaultProperty("Text")]
    [ToolboxData("<{0}:Repeater runat=server></{0}:Repeater>")]
    public class Repeater : System.Web.UI.WebControls.Repeater
    {
        private string _DataName;

        [Description("数据源")]
        public string DataName
        {
            set
            {
                _DataName = value;
                //针对数据源绑定数据
                if (!string.IsNullOrEmpty(_DataName))
                {
                    this.DataSource = QueryDac.GetSource(_DataName);
                    this.DataBind();
                }
            }
            get { return _DataName; }
        }

        private string _Sql;

        [Description("Sql")] 
        public string Sql
        {
            set
            {
                _Sql = value;
                //针对数据源绑定数据
                if (!string.IsNullOrEmpty(_Sql))
                {
                    this.DataSource = QueryDac.GetTable(_Sql);
                    this.DataBind();
                }
            }
            get { return _Sql; }
        }
    }
}
